Fix up some issues I found when porting PPC to the new common gdb stub code:
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 3 Mar 2006 09:53:58 +0000 (10:53 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 3 Mar 2006 09:53:58 +0000 (10:53 +0100)
- cosmetic changes in the messages printed
- 'flags' must always be unsigned long.
- explicitly calling initialize_gdb() is not difficult. For x86 and ia64 I
placed this call immediately before do_initcalls(), since that's where it's
being called from now so we know it's safe. Architecture people can move it
earlier as appropriate.
- I don't understand all these ASSERT(!local_irq_is_enabled()) statements,
sometimes bracketing a single call like receive_command(). How exactly would
receive_command() manage to re-enable irqs? Also, a failing ASSERT would just
call into the stub again anways...
- initialize_gdb() was overcomplicated. serial_parse_handle() already handles
the parsing for us, and there's no need to panic there.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
xen/arch/ia64/xen/xensetup.c
xen/arch/x86/setup.c
xen/common/gdbstub.c
xen/include/xen/gdbstub.h

index 8b6faeed26d7a6d5cdd50a808fbd53885b11e727..38784f77df1402d1f7939836d93dfa929a202859 100644 (file)
@@ -12,7 +12,7 @@
 #include <xen/sched.h>
 #include <xen/mm.h>
 #include <public/version.h>
-//#include <xen/delay.h>
+#include <xen/gdbstub.h>
 #include <xen/compile.h>
 #include <xen/console.h>
 #include <xen/serial.h>
@@ -360,6 +360,8 @@ printk("About to call __cpu_up(%d)\n",i);
     smp_cpus_done(max_cpus);
 #endif
 
+    initialise_gdb(); /* could be moved earlier */
+
     do_initcalls();
 printk("About to call sort_main_extable()\n");
     sort_main_extable();
index ae73fe6ca94ee9e808a5b906e7e5eb7201f841b9..b5b0fd68e04508940c229954b42ead7584b2ffcc 100644 (file)
@@ -13,6 +13,7 @@
 #include <xen/multiboot.h>
 #include <xen/domain_page.h>
 #include <xen/compile.h>
+#include <xen/gdbstub.h>
 #include <public/version.h>
 #include <asm/bitops.h>
 #include <asm/smp.h>
@@ -479,6 +480,8 @@ void __init __start_xen(multiboot_info_t *mbi)
     printk("Brought up %ld CPUs\n", (long)num_online_cpus());
     smp_cpus_done(max_cpus);
 
+    initialise_gdb(); /* could be moved earlier */
+
     do_initcalls();
 
     schedulers_start();
index 48c1b0a41f5cdf364bc50a17d7219e10afa283e1..5f5beb690af169b52fb40bd9a2c8f3e9f5035634 100644 (file)
@@ -376,7 +376,6 @@ process_command(struct cpu_user_regs *regs, struct gdb_context *ctx)
         break;
     case 'g': /* Read registers */
         gdb_arch_read_reg_array(regs, ctx);
-        ASSERT(!local_irq_is_enabled());
         break;
     case 'G': /* Write registers */
         gdb_arch_write_reg_array(regs, ctx->in_buf + 1, ctx);
@@ -395,7 +394,6 @@ process_command(struct cpu_user_regs *regs, struct gdb_context *ctx)
             return 0;
         }
         gdb_cmd_read_mem(addr, length, ctx);
-        ASSERT(!local_irq_is_enabled());
         break;
     case 'M': /* Write memory */
         addr = simple_strtoul(ctx->in_buf + 1, &ptr, 16);
@@ -477,7 +475,7 @@ __trap_to_gdb(struct cpu_user_regs *regs, unsigned long cookie)
 {
     int resume = 0;
     int r;
-    unsigned flags;
+    unsigned long flags;
 
     if ( gdb_ctx->serhnd < 0 )
     {
@@ -506,7 +504,7 @@ __trap_to_gdb(struct cpu_user_regs *regs, unsigned long cookie)
 
     if ( !gdb_ctx->connected )
     {
-        printk("GDB connection activated\n");
+        printk("GDB connection activated.\n");
         gdb_arch_print_state(regs);
         gdb_ctx->connected = 1;
     }
@@ -522,7 +520,7 @@ __trap_to_gdb(struct cpu_user_regs *regs, unsigned long cookie)
 
     /* Shouldn't really do this, but otherwise we stop for no
        obvious reason, which is Bad */
-    printk("Waiting for GDB to attach to Gdb\n");
+    printk("Waiting for GDB to attach...\n");
 
     gdb_arch_enter(regs);
     gdb_ctx->signum = gdb_arch_signal_num(regs, cookie);
@@ -535,9 +533,7 @@ __trap_to_gdb(struct cpu_user_regs *regs, unsigned long cookie)
 
     while ( resume == 0 )
     {
-        ASSERT(!local_irq_is_enabled());
         r = receive_command(gdb_ctx);
-        ASSERT(!local_irq_is_enabled());
         if ( r < 0 )
         {
             dbg_printk("GDB disappeared, trying to resume Xen...\n");
@@ -545,9 +541,7 @@ __trap_to_gdb(struct cpu_user_regs *regs, unsigned long cookie)
         }
         else
         {
-            ASSERT(!local_irq_is_enabled());
             resume = process_command(regs, gdb_ctx);
-            ASSERT(!local_irq_is_enabled());
         }
     }
 
@@ -561,28 +555,14 @@ __trap_to_gdb(struct cpu_user_regs *regs, unsigned long cookie)
     return 0;
 }
 
-/*
- * initialization
- * XXX TODO
- *     This should be an explicit call from architecture code.               
- *     initcall is far too late for some early debugging, and only the 
- *     architecture code knows when this call can be made.          
- */
-static int
-initialize_gdb(void)
+void
+initialise_gdb(void)
 {
-    if ( !strcmp(opt_gdb, "none") )
-        return 0;
     gdb_ctx->serhnd = serial_parse_handle(opt_gdb);
-    if ( gdb_ctx->serhnd == -1 )
-        panic("Can't parse %s as GDB serial info.\n", opt_gdb);
-
-    printk("Gdb initialised.\n");
-    return 0;
+    if ( gdb_ctx->serhnd != -1 )
+        printk("GDB stub initialised.\n");
 }
 
-__initcall(initialize_gdb);
-
 /*
  * Local variables:
  * mode: C
index 9d2e323aedb5388e09a81c569b5ee8f3d4f78187..609831de9514b41163026a368ee9e8719a81441f 100644 (file)
@@ -21,6 +21,8 @@
 #ifndef __XEN_GDBSTUB_H__
 #define __XEN_GDBSTUB_H__
 
+#ifdef CRASH_DEBUG
+
 /* value <-> char (de)serialzers for arch specific gdb backends */
 char hex2char(unsigned long x); 
 int char2hex(unsigned char c); 
@@ -84,6 +86,14 @@ void gdb_arch_exit(struct cpu_user_regs *regs);
 #define SIGALRM         14
 #define SIGTERM         15
 
+void initialise_gdb(void);
+
+#else
+
+#define initialise_gdb() ((void)0)
+
+#endif
+
 #endif /* __XEN_GDBSTUB_H__ */
 
 /*